package com.zxq.web.notifyplatfrom.impl;

import com.zxq.exchange.model.ExchangeDTO;
import com.zxq.exchange.register.INotifyPlatform;
import com.zxq.factory.FastFrame;
import com.zxq.frame.fangyan.FangYanDataFrame;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class FYChargePilePlatform implements INotifyPlatform {

    @Autowired
    GeneralNotifyPlatform generalNotifyPlatform;


    /**
     * cmdHex 为 版本号 + 功能码 + 确认编号
     * @param exchangeDTO
     */
    @Override
    public void notifyPlatform(ExchangeDTO exchangeDTO) {
       byte[] dataBuff = exchangeDTO.getData();
       FangYanDataFrame fangYanDataFrame = new FangYanDataFrame();
       FastFrame.decoder(fangYanDataFrame,dataBuff);
       log.info(fangYanDataFrame.toString());
       String blockKey =  exchangeDTO.getBlockKey() + fangYanDataFrame.getAck();
       exchangeDTO.setBlockKey(blockKey);
       exchangeDTO.setData(fangYanDataFrame.getData());
       generalNotifyPlatform.notifyPlatform(exchangeDTO);

    }

}
